<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<meta http-equiv="x-ua-compatible" content="ie=7" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link href="<%=path%>/css/main.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/dialog.css" rel="stylesheet" type="text/css" />
		<link href="<%=path%>/css/list.css" rel="stylesheet" type="text/css" />
		<script language="javascript" type="text/javascript" src="<%=path%>/js/include.js"></script>
		<script language="javascript" type="text/javascript" src="<%=path%>/calendar/WdatePicker.js"></script>
		<script language="JavaScript" type="text/javascript" src="<%=path%>/js/caltimer.js"></script>
		<script type="text/javascript" src="<%=path%>/js/jquery.form.js"></script>
	</head>

	<body class="fullbody">
		<div class="context">
			<div class="position">
				<div class="tposi">
					当前位置：
					<a href="javascript:changeMenu(1,'<%=request.getContextPath()%>/infopub/pubmain?menuid=1');" class="linkstyle">首页</a>&nbsp;&gt;&gt;&nbsp;
					<a href="javascript:changeMenu(4,'')" class="linkstyle">自助服务</a>&nbsp;&gt;&gt;&nbsp;
					<span class="curposition">资质分类管理</span>
				</div>
				<div class="help">
					<a href="javascript:void(null);" onclick="doHelp('<%=request.getContextPath()%>/help/html/ZZFLGL.html');" class="linkstyle">帮助</a>
				</div>
			</div>
			<div class="margin8"></div>
			<div class="subpage_title">
			<div class="title_index">
				<img src="<%=path%>/images/common/dot03.gif" alt="" border="0" />
					&nbsp;资质分类管理
			</div>
			<div class="rollback"></div>
		</div>
		<div class="margin20"></div>
			<form  id="form2" name="form2"  method="post">
				<input type="hidden" name="pk_file" value=""/>
				<input type="hidden" name="subType" value=""/>
				<div class="productlist">
					<div><b>资质分类</b></div>
					<div class="margin10"></div>
					<div class="spliter_line"></div>
					<div class="margin10"></div>
					<div>
						<table border="0" cellpadding="0" cellspacing="0" id="qaList"
							class="subpage_table1 withborder2" align="center" width="800">
							<tr>
								<th class="w_04">序号</th>
								<th class="w_02">专业资质分类名称</th>
								<th class="w_04" >操作</th>
							</tr>
							<c:if test="${qualtityType!=null}">
								<c:forEach items="${qualtityType}" var="qualtity"
									varStatus="index">
									<tr align="center" id="${qualtity.pk_qacode}">
										<td>${index.count}</td>
										<td>
											<input type='text' class='list_text_1' name='name' id='${qualtity.pk_qacode}-name'value='${qualtity.name}' readOnly/>
											<input type="hidden" name="status" value="${qualtity.qastatus}"/>
											<input type="hidden" name="validdate" value="${qualtity.date}"/>
											<input type="hidden" name="qaRank" value="${qualtity.qarank}"/>
										</td>
										<td class="w_04">
											<a href="javascript:deleteRowById('${qualtity.pk_qacode}')" class="linkstyle3">删除</a>
											<input type="hidden" name="pkQaCl" value="${qualtity.pk_qacode}" />
										</td>
									</tr>
								</c:forEach>
							</c:if>
						</table>
						<table border="0" cellpadding="0" cellspacing="0"
							class="subpage_table1 withborder2" align="center" width="800">
							<tr>
								<td colspan="9">
									&nbsp;
									<img alt="" src="<%=path%>/images/common/add.png" border="0" />
									&nbsp;
									<a href="javascript:showDialog('add','${size}');"
										class="linkstyle3">添加新的资质分类</a>
								</td>
							</tr>
						</table>
					</div>
					<div class="margin10"></div>
					<div class="margin10"></div>
					<div><b>资质分类附件</b></div>
					<div class="margin10"></div>
					<div class="spliter_line"></div>
					<div>
						<table  width="800">
							<tr>
								<td class="memoFont">
									注：上传的资质文件内容包括但不限于：最新经过年检的营业执照、税务登记证、组织机构代码证、特殊行业资质证（有效期年限内），体系认证的资质证，财务报表，如是代理企业，需提供代理授权书。
								</td>
							</tr>
							<tr style="height:15px">
								<td />
							</tr>
						</table>
						<table border="0" cellpadding="0" cellspacing="0" id="fileList"
							class="subpage_table1 withborder2" align="center" width="800">
							<tr>
								<th class="w_02">附件名称<span class="needfill">*</span></th>
								<th class="w_02">附件内容说明</th>
								<th class="w_02">上传附件</th>
								<th class="w_02">上传时间</th>
								<th class="w_04" >操作</th>
							</tr>
							<c:if test="${infoCheckFileItemVos!=null}">
								<c:forEach items="${infoCheckFileItemVos}" var="infoCheckFile"
									varStatus="index">
									<tr align="center" id="${infoCheckFile.pkFile}">
										<input type="hidden" name="pkFile" value="${infoCheckFile.pkFile}"/>
										<td><input type="text" class="list_text_2" name="fileAlias" id="fileAlias" value="${infoCheckFile.fileAlias}" /></td>
										<td><input type="text" class="list_text_2" name="fileMemo" id="fileMemo" value="${infoCheckFile.fileMemo}" /></td>
										<td>${infoCheckFile.fileName}</td>
										<td>${infoCheckFile.creatDate}</td>
										<td><a onclick="delFile('${infoCheckFile.pkFile}')" class="linkstyle3">删除</a></td>
									</tr>
								</c:forEach>
							</c:if>
						</table>
						<table border="0" cellpadding="0" cellspacing="0"
							class="subpage_table1 withborder2" align="center" width="800">
							<tr>
								<td colspan="9">
									&nbsp;
									<img alt="" src="<%=path%>/images/common/add.png" border="0" />
									&nbsp;
									<a onclick="uploadFile()" class="linkstyle3">添加附件</a>
								</td>
							</tr>
						</table>
					</div>
					<div class="margin8"></div>
					<div class="buttonrow">
						<input type="button" class="buttonok" value="提交" onclick="submitQaCl()" />
					</div>
					
					<div class="margin20"></div>
					<div id="message" class="msgcolor">
						<c:out value="${system_err_msg}" />
					</div>
				</div>
			</form>
		</div>
		
		<script language="javascript">
			function showDialog(type,index){
				var url = "url:post?<%=path%>/selfinfo/editqualtity?type="+type+"&index="+index;
				dialog("添加资质分类", url,"500", "auto", "","");
			}
			//修改行
			function editRowById(pkCl) {
				var iframe="iframe:<%=path%>/selfservice/selfservice/qualtity.jsp?pkCl="+pkCl;
				 dialog("资质分类修改",iframe,"500","250","","");
			}
			//删除行
			function deleteRowById(pkCl) {
				var root = document.all("qaList");
				var rows = root.rows;
				//寻找到对应的删除行并进行删除
				for(var pos = 1; pos < rows.length; pos++) {
					var temprow = rows[pos];
					if(temprow.id == pkCl) {
						root.deleteRow(pos);
						break;
					}
				}
				//当删除行操作时更新显示索引
				//当删除行操作时更新显示索引
				for(var pos = 1; pos < rows.length; pos++) {
					var temprow = rows[pos];
					var cells = temprow.cells;
					var cell = cells[0];
					if(typeof(cell) == 'object') {
						cell.innerHTML = pos;
					}
				}	 
			}

			function submitQaCl(){
			    var ErrMsg = checkField();
				if(ErrMsg!=null && trim(ErrMsg)!=""){
					alert(ErrMsg);
					return;
				}
				form2.action="<%=path%>/selfinfo/submitqualtity";
				form2.submit();
			}
			//上传文件
			function uploadFile(){
				var url = "<%=path%>/sourcingcoll/fileupload.jsp";
				url = url + "?" + "uploadMode=7";
				url = url + "&" + "userCode=";
				url = url + "&" + "isNeedAddRow=Y";
				window.open(url,'' ,'width=640,height=330,location=no');
			}
			
			function addFileRow(pkReleaseFileB,fileName,fileSize,replyFilePath){
				if(replyFilePath!=null){
					var fileInfos=replyFilePath.split("#");
					var pkFile=fileInfos[0];
					var creater=fileInfos[1];
					var creatTime=fileInfos[2];
					creatTime=creatTime.substring(0,19);
					
					var fileTable = document.getElementById("fileList");
					var rowNo = fileTable.rows.length;
					var row = fileTable.insertRow();
					row.id = rowNo;
					//文件名称
					var cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<td><input type='text' class='list_text_2' name='fileAlias' id='fileAlias' value='' /></td>";
					 
					//内容说明
					var cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<td><input type='text' class='list_text_2' name='fileMemo' id='fileMemo' value='' /></td>";
					 
					//上传附件
					cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<td>"+fileName+"</td>";
		
					//上传时间				
					cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<td>"+creatTime+"</td>";
					
					//删除
					cell = row.insertCell()
					cell.align = 'center';
					cell.innerHTML = "<a onclick=delFile('"+(rowNo)+"') class='linkstyle3'>删除</a><input type='hidden' name='pkFile' value='"+pkFile+"'/><input type='hidden' name='pkQaCl' value='' />";
				}
			}
			
			function delFile(index){
				var fileList = document.getElementById("fileList");
				if (fileList != null) {
					// 获取报价信息有多少行
					var rows = fileList.rows;
					if (rows != null && rows.length > 0) {
						for ( var pos = 0; pos < rows.length; pos++) {
							var row = rows[pos];
							// 寻找要删除的row
							if (row.id == index) {
								fileList.deleteRow(pos);
								deleteFile(index);
								break;
							}
						}
					}
				}
			}
			function deleteFile(pk_file){
				document.form2.pk_file.value = pk_file;
				document.form2.action="<%=path%>/ebvpfile/deletefile";
				//提交表单
				var options3 = {
					beforeSubmit : showRequest3, 
					success : showResponse3
				};
				$('#form2').ajaxSubmit(options3);
			}
			
			function showRequest3(formData, jqForm, options) {
			}
			function showResponse3(responseText, statusText, xhr, $form) {
			}
			
			
			//必输项校验
			function checkField(){
				 var fileAliasElms = document.getElementsByName("fileAlias");
					
				if(fileAliasElms != null){
					for(var i=0; i<fileAliasElms.length; i++){
						var fileAliasVal = fileAliasElms[i].value;
						if(fileAliasVal == null ||trim(fileAliasVal)==""){
								return "附件名称不允许为空!";
						}
					}
				}
					
				return null;
			}
			
			function trim(strToTrim) { 
			     result=strToTrim 
			     for (_i=0; _i<strToTrim.length; _i++) { 
			            if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(_i+1) 
			            else _i=strToTrim.length 
			     } 
			     strToTrim=result 
			     for (_i=strToTrim.length-1; _i>=0; _i--) { 
			            if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(0,_i) 
			            else _i=0 
			      } 
	       		return result 
			} 
		</script>
	</body>
</html>
